#![allow(unused_must_use)]
#![feature(proc_macro_hygiene, decl_macro)]

#[macro_use] extern crate rocket;

use rocket::config::{Config, Environment};

use common::cors::get_cors;
use config::CONFIG;

fn main() {
    let config = Config::build(Environment::Development)
        .address("localhost")
        .port(CONFIG.port as u16)
        .finalize()
        .expect("config error");

    rocket::custom(config)
        .attach(get_cors())
        // mount the catch all routes
        .mount("/", routes![
            controller::index_controller::index,
            controller::post_controller::list_posts,
            controller::post_controller::page,
            controller::post_controller::get_by_id,
            controller::post_controller::add,
            controller::post_controller::update,
            controller::post_controller::delete
         ])
        .launch();
}
